package org.gdsdxy.pmmp.dao;

import java.util.List;

import org.gdsdxy.pmmp.entity.Friend;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class FriendDaoImpl extends HibernateDaoSupport implements
		IFriendDao {

	@Override
	public void delete(Friend f) {
		this.getHibernateTemplate().delete(f);
	}

	@Override
	public List<Friend> getFriendsById(int userId, String ensure) {
		String hql = "from Friend where user.ID = ? and ensure = ?";
    
		return this.getHibernateTemplate().find(hql,new Object[]{userId,ensure});
	}

	@Override
	public void save(Friend f) {
		this.getHibernateTemplate().save(f);
	}

	@Override
	public void udpate(Friend f) {
		this.getHibernateTemplate().saveOrUpdate(f);
	}

	@Override
	public Friend get(Integer id) {
		// TODO Auto-generated method stub
		return (Friend) this.getHibernateTemplate().get(Friend.class, id);
	}

}
